package com.chrray.position.util.wx;

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.web.client.RestTemplate;

@Slf4j
public class AliUtil {



    public static JSONObject getRealName(String idCard, String name, String appCode) {


        String url="https://idcert.market.alicloudapi.com/idcard?idCard="+ idCard +"&name="+name;

        RestTemplate re = new RestTemplate();

        // 请求头
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Type", "application/json;charset=UTF-8");
        headers.add("Authorization", "APPCODE "+appCode);

        HttpEntity entity = new HttpEntity<>(headers);

        HttpEntity<JSONObject> jsonObject = re.exchange(url, HttpMethod.GET,entity, JSONObject.class);
        log.info("调用实名认证结果：{}",jsonObject.getBody());
        return jsonObject.getBody();
    }

}
